package JavaMap;

import java.util.HashMap;

public class JavaMapTest {

    /**
     *  Java 用自定义类型作为HashMap的键
     *  https://segmentfault.com/a/1190000002655085
     */
    public static void main(String[] args){

        HashMap<Person, String> map = new HashMap<Person, String>();

        map.put(new Person("001"), "aaa");
        map.put(new Person("002"), "bbb");
        map.put(new Person("003"), "ccc");
        map.put(new Person("003"), "ddd");

        System.out.println(map.toString());
        System.out.println(map.get(new Person("001")));
        System.out.println(map.get(new Person("002")));
        System.out.println(map.get(new Person("003")));
    }


}
